<!DOCTYPE HTML>
<html>
<head>
    <meta charset="UTF-8">
    <@h.head/>
    <script type="text/javascript">

       /* $(function(){
           if(navigator.userAgent.toLowerCase().indexOf("chrome") == -1){
               $('#loadGG').css('display','block')
               $('#loadGG').dialog({
                   title: '温馨提示',
                   width: 350,
                   height: 150,
                   closable: false,
                   closed: false,
                   isTop:true,
                   // onClose: function(){
                   //     tableId.dialog('destroy'); //销毁dialog对象
                   // },
                   cache: false,
                   modal: true
               });

           }else{
           }
       }) */
       function loadHref(){
           var agent = navigator.userAgent.toLowerCase();
           if (agent.indexOf("win64") >= 0 || agent.indexOf("wow64") >= 0) {
               window.open('${resPath}/download/ChromeStandaloneSetup64.exe','_blank');
           }
           else {
               window.open('${resPath}/download/ChromeStandaloneSetup.exe','_blank');
           }
       }
        //在最上层打开登录页面
        if (window.top!=window.self)
        {
            window.top.location=window.location.href + "${ (toUrl??)?string('?toUrl='+toUrl!, '') }"
        }
    </script>


    <link rel="stylesheet" type="text/css" href="${resPath}/easyui/themes/m-style/in_basis.css?v=${version}" />
    <script type="text/javascript" src="${resPath}/easyui/plugins/in_basis.js?v=${version}"></script>
    <script type="text/javascript" src="${resPath}/js/jsencrypt.min.js?v=${version}"></script>
    <script type="text/javascript" src="${resPath}/js/base64.min.js?v=${version}"></script>
    
    <title>${sys_name!} 登录</title>
    
    <script type="text/javascript">
     var temppwd = "********";
     $(function(){
          var userinfo = getCookie("jdgm_platform");
          if (userinfo != null && userinfo != "") {
              var account = userinfo.split(",")[0];
              var password = userinfo.split(",")[1];
              document.getElementById('account').value = account;
              document.getElementById('encryptPwd').value = password;
              document.getElementById('password').value = temppwd;
          }
          var rememberMe = getCookie("jdgm_platform_rememberMe");
          if (rememberMe == "1") {
              document.getElementById('cookie_rememberme').checked = true;
          }else{
        	  document.getElementById('cookie_rememberme').checked = false;
          }
      });
        var flag = true;
        $(function(){
        //已记住密码进入登录登录页面时，让密码框获取焦点
          var password =$("#password").val();
          if(password){
            setTimeout("$('#password').focus()",600);
          }else{
            setTimeout("$('#account').focus()",2000);
          }
          
          var errorMsg = "${message!}";
          if(errorMsg!=""){
              Msg.error("错误", errorMsg);  
          }

            //回车提交事件
            $("body").keydown(function(e){
                var curKey = e.which;
                if(curKey == 13){//keyCode=13是回车键
                    if(flag){
                       $('#btnLogin').click();  
                       flag=false;
                    }
                    
                }
            });   
        });
        
        function checkForm(){
        	
            if($("#account").val()==""){
                $('#account').focus();
                Msg.error("错误", "用户名不能为空");
                flag=true;
                return false;
            }
            if($("#password").val()=="" && $("#encryptPwd").val()==""){
                $('#password').focus();
                Msg.error("错误", "密码不能为空");
                flag=true;
                return false;
            }
            if($("#password").val()!="" && $("#password").val()!=temppwd){
	            var crypt = new JSEncrypt();
	        	crypt.setPublicKey($("#pubKey").val());
	
	        	// Encrypt the data with the public key.
	        	var enc = crypt.encrypt($("#password").val());
	        	enc = Base64.encode(enc);
	            $("#encryptPwd").val(enc);
            }
        	//ajaxSubmitForm2("loginForm", "${ctx}/security/sso/check", function(result){
                var cname = "jdgm_platform";
                var rememberMe = document.getElementById('cookie_rememberme').checked;
                if (rememberMe) {
                    var account = document.getElementById('account').value;
                    var password = document.getElementById('encryptPwd').value;
                    setCookie(cname,account+","+password,9999999);
                    setCookie("jdgm_platform_rememberMe","1",11999999);
                }else{
                    clearCookie(cname);
                    clearCookie("jdgm_platform_rememberMe");
                }
                //loadhrefcage('${ctx}'+result.data, 100);
        	//}, 
			//function(result){
            //    flag=true;
            //    Msg.error("错误",result.message);
        	//});
            
            return true;
        }
        

      //设置cookie
        function setCookie(cname, cvalue, exdays) {
            var d = new Date();
            d.setTime(d.getTime() + (exdays*24*60*60*1000));
            var expires = "expires="+d.toUTCString();
            document.cookie = cname + "=" + encodeURIComponent(cvalue) + "; " + expires + ";path=/";
            //document.cookie = cname + "=" + cvalue + "; " + expires;
        }

        //获取cookie
        function getCookie(cname) {
            var name = cname + "=";
            var ca = document.cookie.split(';');
            for(var i=0; i<ca.length; i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1);
                if (c.indexOf(name) != -1) return decodeURIComponent(c.substring(name.length, c.length));
                //if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
            }
            return "";
        }

        //清除cookie  
        function clearCookie(name) {  
            setCookie(name, "", -1);  
        }

     
    </script>
</head>
<style>
.login_promot{
    position: absolute;
    right: 6%;

}
</style>
<body class="dindex_bg" id="alltran">
<div id="loadGG" hidden style="padding:5px 15px 15px 15px;height:150px;" >
    <p>请使用谷歌浏览器，否则相关功能将不能正常使用！</p>
    <a onclick="loadHref()" href="javascript:void(0)">点击下载谷歌浏览器</a>
</div>
    <div class="backImg">
        <img class="khhjP" src="../../images/dl7.png" alt="">
    </div>
    <div class="bg_login_box01"></div>
    <div class="bg_login_box02"></div>
    <div class="login_box">
        <div class="login_box01"></div>
        <input type="hidden" id="pubKey" name="pubKey" value="${pubKey!}"/>
        <form id="loginForm" autocomplete="off" action="${ctx}/security/sso/check" method="post" data-toggle="validator" role="form">
        <div class="login_box02">
            <div class="input_icon">
                <span class="icon_user"></span>
                <span class="icon_password"></span>
            </div>
            <input id="account" name="account" autocomplete="off" type="text" class="login_input01 input_user float_l" value="" maxlength="16"/>
            <input id="password" type="password" name="password" autocomplete="off" class="login_input01 input_password float_l" value=""  maxlength="16"/>
            <input id="encryptPwd" type="hidden" name="encryptPwd"/>
            <input id="toUrl" name="toUrl" type="hidden" value="${toUrl!ctx+'/decision/view/report?viewlet=city.cpt'}" />
            
            <div class="login_checkbox">
                <input id="cookie_rememberme" name="cookie_rememberme" type="checkbox" value=""/>
                <label for="cookie_rememberme">记住密码</label>
            </div>
            <button id="btnLogin" type="submit" class="login_button01" data-text="登&nbsp;&nbsp;录">
                <span>登&nbsp;&nbsp;录</span>
            </button>
        </div>
        </form>
    </div>

    <div class="footer">
            <div class="login_promot">
                    <a style="color:#fff;" onclick="loadHref()" href="javascript:void(0)">单击此处下载谷歌浏览器</a>
                </div>
      ${sys_desc!}
    </div>
    
<script type="text/javascript">
var submitBtn = document.getElementById("btnLogin");

submitBtn.onclick = function (event) {
	return checkForm();
};
</script>
</body>
</html>
